//查询代发货订单
var page = 0;
var offset = 0;
var pageSize = 5;
var j=5;

function requestData(){
	
		$.ajax({
			url:"http://localhost:16111/orderform/daifahuo",
			mimeType: "post",
			dataType: "json",
			data:{
				q:0,
				j:j,
				
			},
			xhrFields:{withCredentials: true},
			success:function(date){
				
				var str="";
				for(i in date){
					var time=new Date(date[i].undertime);
					var time2=time.getFullYear()+"-"+time.getMonth()+"-"+time.getDay();
					var time3=new Date(date[i].deliverytime);
					var time4=time.getFullYear()+"-"+time.getMonth()+"-"+time.getDay();
					
				str+="<tr>"+
				"<td>"+ date[i].orderid +"</td>"+
				"<td>"+ date[i].ordernumber +"</td>"+
				"<td>"+ date[i].ordernumber +"</td>"+
				"<td>"+time2+"</td>"+
				"<td>"+ date[i].consignee+"</td>"+
				"<td>"+ date[i].telephone+"</td>"+
				"<td>"+ time4 +"</td>"+
				"<td>"+ date[i].addressinformation +"</td>"+
				"<td>"+ date[i].orderstatus +"</td>"+
				
				"<td><button onclick='chuan(\""+ date[i].orderid +"\",\""+ date[i].spid +"\")'>立即发货</button></td>"
				;
				}
				
				document.getElementById("tab").innerHTML = str;
				
			},
			
		})
		
	};
	
	
		 
			function chuan(orderid,spid){
				localStorage.setItem("orderid",orderid);
				localStorage.setItem("spid",spid)
				lijifahuo();
			}
		       

				
				//立即发货
				function lijifahuo(){
					var orderid =localStorage.getItem("orderid");
					var spid=localStorage.getItem("spid");
					alert(orderid);
					$.ajax({
					url: "http://localhost:16111/orderform/backfahuo",
					method: "post",
					dataType: "json",
					 data:{
						 orderid:orderid,
						 spid:spid
						},
						xhrFields:{withCredentials: true},
							success: function(date) {
							alert("修改成功");
							
						},
						
								error: function(text) {
									var json = eval(text);
									alert(text.toString()+"111");
									
								}
							})
							}
							
							
							//退款中
							function backseletuikuan(){
									$.ajax({
										url:"http://localhost:16111/orderform/backtuikuan",
										mimeType: "post",
										dataType: "json",
										
										xhrFields:{withCredentials: true},
										success:function(date){
											
											var str="";
											for(i in date){
												var time=new Date(date[i].updatime);
												var time2=time.getFullYear()+"-"+time.getMonth()+"-"+time.getDay();
											str+="<tr>"+
				"<td>"+ date[i].id +"</td>"+
				
				"<td>"+ date[i].ordernumber +"</td>"+
				"<td>"+date[i].servicetype+"</td>"+
				"<td>"+ date[i].cargostatus+"</td>"+
				"<td>"+ date[i].price+"</td>"+
				"<td>"+ date[i].refundreason +"</td>"+
				
				"<td>"+ date[i].shoopname +"</td>"+
				"<td>"+ date[i].ordercolor +"</td>"+
				"<td>"+ date[i].ordersieze +"</td>"+
				"<td>"+ time2 +"</td>"+
				"<td>"+ date[i].tkstatus +"</td>"+
				"<td><button onclick='shouhuochuan("+ date[i].id +")'>同意</button><button onclick='chuan("+ date[i].id +")'>不同意</button></td>"
				;
											}
											
											document.getElementById("tab1").innerHTML = str;
										},
										
									})
									
								};
								//退款成功
								function selecopys2(){
										$.ajax({
											url:"http://localhost:16111/orderform/selecopys2",
											mimeType: "post",
											dataType: "json",
											
											xhrFields:{withCredentials: true},
											success:function(date){
												
												var str="";
												for(i in date){
													var time=new Date(date[i].updatime);
													var time2=time.getFullYear()+"-"+time.getMonth()+"-"+time.getDay();
												str+="<tr>"+
				"<td>"+ date[i].id +"</td>"+
				
				"<td>"+ date[i].ordernumber +"</td>"+
				"<td>"+date[i].servicetype+"</td>"+
				"<td>"+ date[i].cargostatus+"</td>"+
				"<td>"+ date[i].price+"</td>"+
				"<td>"+ date[i].refundreason +"</td>"+
				
				"<td>"+ date[i].shoopname +"</td>"+
				"<td>"+ date[i].ordercolor +"</td>"+
				"<td>"+ date[i].ordersieze +"</td>"+
				"<td>"+ time2 +"</td>"+
				"<td>"+ date[i].tkstatus +"</td>"
				;
												}
												
												document.getElementById("tab1").innerHTML = str;
												
											},
											
										})
										
									};
								
								
								//同意退款传值
								function backchuan(id){
									localStorage.setItem("id",id);
									backupdacopy1();
									backupdacopy2();
								}
								

								   
								
									
									//修改copy1
									function backupdacopy1(){
										var orderid =localStorage.getItem("orderid");
										alert(orderid);
										$.ajax({
										url: "http://localhost:16111/orderform/backupdacopy1",
										method: "post",
										dataType: "json",
										 data:{
											 orderid:orderid
											},
											xhrFields:{withCredentials: true},
												success: function(data) {
												alert("修改成功");
												
											},
											
													error: function(text) {
														var json = eval(text);
														alert(text.toString()+"111");
														
													}
												})
												}
												
												
												//修改copy2
												function backupdacopy2(){
													var id =localStorage.getItem("id");
													alert(id);
													$.ajax({
													url: "http://127.0.0.1:16700/backupdacopy2",
													method: "post",
													dataType: "json",
													 data:{
														 id:id
														},
														xhrFields:{withCredentials: true},
															success: function(data) {
															alert("修改成功");
															backseletuikuan();
															
														},
														
																error: function(text) {
																	var json = eval(text);
																	alert(text.toString()+"111");
																	
																}
															})
															}
																				
								
					//不同意退款传值
					function backchuan2(id){
						localStorage.setItem("id",id);
						backupdacopy3();
					}			
								
					//不同意修改copy1
					function backupdacopy3(){
						var orderid =localStorage.getItem("orderid");
						alert(orderid);
						$.ajax({
						url: "http://localhost:16111/orderform/backupdacopy3",
						method: "post",
						dataType: "json",
						 data:{
							 orderid:orderid
							},
							xhrFields:{withCredentials: true},
								success: function(data) {
								alert("修改成功");
								
							},
							
									error: function(text) {
										var json = eval(text);
										alert(text.toString()+"111");
										
									}
								})
								}			
								
								
								function selefahuo(){
										$.ajax({
											url:"http://localhost:16111/orderform/fahuochengg",
											mimeType: "post",
											dataType: "json",
											data:{
												userid:userid,
											},
											xhrFields:{withCredentials: true},
											success:function(date){
												
												var str="";
												for(i in date){
													var time=new Date(date[i].deliverytime);
													var time2=time.getFullYear()+"-"+time.getMonth()+"-"+time.getDay();
													var time3=new Date(date[i].deliverytime);
													var time4=time.getFullYear()+"-"+time.getMonth()+"-"+time.getDay();
												str+="<tr>"+
												"<td>"+ date[i].orderid +"</td>"+
												"<td>"+ date[i].ordernumber +"</td>"+
												"<td>"+ date[i].ordernumber +"</td>"+
												"<td>"+time2+"</td>"+
												"<td>"+ date[i].consignee+"</td>"+
												"<td>"+ date[i].telephone+"</td>"+
												"<td>"+ time4 +"</td>"+
												"<td>"+ date[i].addressinformation +"</td>"+
												"<td>"+ date[i].orderstatus +"</td>";
												}
												document.getElementById("tab1").innerHTML = str;
												
											},
											
										})
										
									};
									
									
									
									
	function seleshouhuo(){
		$.ajax({
			url:"http://localhost:16111/orderform/seleshouhuo",
			mimeType: "post",
			dataType: "json",
			data:{
				q:0,
				j:j,
				
			},
			xhrFields:{withCredentials: true},
			success:function(date){
				
				var str="";
				for(i in date){
					var time=new Date(date[i].updatime);
					var time2=time.getFullYear()+"-"+time.getMonth()+"-"+time.getDay();

					
				str+="<tr>"+
				"<td>"+ date[i].id +"</td>"+
				
				"<td>"+ date[i].ordernumber +"</td>"+
				"<td>"+date[i].servicetype+"</td>"+
				"<td>"+ date[i].cargostatus+"</td>"+
				"<td>"+ date[i].price+"</td>"+
				"<td>"+ date[i].refundreason +"</td>"+
				
				"<td>"+ date[i].shoopname +"</td>"+
				"<td>"+ date[i].ordercolor +"</td>"+
				"<td>"+ date[i].ordersieze +"</td>"+
				"<td>"+ time2 +"</td>"+
				"<td>"+ date[i].tkstatus +"</td>"+
				"<td><button onclick='shouhuochuan("+ date[i].id +")'>同意</button><button onclick='chuan("+ date[i].id +")'>不同意</button></td>"
				;
				}
				
				document.getElementById("tab").innerHTML = str;
			},
			
		})
		
	};


								

			function shouhuochuan(id){
				localStorage.setItem("id",id);
				shouhuotongyi();
				shouhuotongyi2();
			}
		       

				
				//收货同意退款改表二
				function shouhuotongyi(){
					var id =localStorage.getItem("id");
					alert(id);
					$.ajax({
					url: "http://localhost:16111/orderform/updashouhuotongyi",
					method: "post",
					dataType: "json",
					 data:{
						 id:id
						},
						xhrFields:{withCredentials: true},
							success: function(data) {
							alert("修改成功");
							alert(111);
						},
						
								error: function(text) {
									var json = eval(text);
									alert(text.toString()+"111");
									
								}
							})
							}
				
				
				//收货同意退款改表一
				function shouhuotongyi2(){
					var id =localStorage.getItem("id");
					alert(id);
					$.ajax({
					url: "http://localhost:16111/orderform/updacopytongyi",
					method: "post",
					dataType: "json",
					 data:{
						 orderid:id
						},
						xhrFields:{withCredentials: true},
							success: function(data) {
							alert("修改成功");
							alert(222);
						},
						
								error: function(text) {
									var json = eval(text);
									alert(text.toString()+"111");
									
								}
							})
							}
				
				
				function shouhuobutongyi(id){
				localStorage.setItem("id",);
				shouhuobutongyi();
			}

				//收货不同意退款改表一
				function shouhuobutongyi(){
					var orderid =localStorage.getItem("id");
					alert(orderid);
					$.ajax({
					url: "http://127.0.0.1:16700/updashouhuobutongyi",
					method: "post",
					dataType: "json",
					 data:{
						 orderid:orderid
						},
						xhrFields:{withCredentials: true},
							success: function(data) {
							alert("修改成功");
							
						},
						
								error: function(text) {
									var json = eval(text);
									alert(text.toString()+"111");
									
								}
							})
							}

	



//收货 查看同意
function seleshouhuotongyi(){
		$.ajax({
			url:"http://localhost:16111/orderform/seleshouhuotongyi",
			mimeType: "post",
			dataType: "json",
			data:{
				q:0,
				j:j,
				userid:userid
			},
			xhrFields:{withCredentials: true},
			success:function(date){
				
				var str="";
				for(i in date){
					var time=new Date(date[i].updatime);
					var time2=time.getFullYear()+"-"+time.getMonth()+"-"+time.getDay();

					
				str+="<tr>"+
				"<td>"+ date[i].id +"</td>"+
				
				"<td>"+ date[i].ordernumber +"</td>"+
				"<td>"+date[i].servicetype+"</td>"+
				"<td>"+ date[i].cargostatus+"</td>"+
				"<td>"+ date[i].price+"</td>"+
				"<td>"+ date[i].refundreason +"</td>"+
				
				"<td>"+ date[i].shoopname +"</td>"+
				"<td>"+ date[i].ordercolor +"</td>"+
				"<td>"+ date[i].ordersieze +"</td>"+
				"<td>"+ time2 +"</td>"+
				"<td>"+ date[i].tkstatus +"</td>"
				;
				}
				
				document.getElementById("tab1").innerHTML = str;
			},
			
		})
		
	};
								
								